package lzw.codec.managers;

import java.io.IOException;
import java.util.Map;

/**
 * This class is responsible to make all manipulations related to files, which is
 * load and file generations.
 * 
 * @author Bruno Cartaxo
 * 
 * @since SEP 2009
 */
public abstract class LZWFileManager {

	public static LZWFileManager getInstance() {
		return LZWFileManagerImpl.getInsntace();
	}
	
	/**
	 * This method is responsibly to load the initial dictionary file (only with 
	 * root characters), that will be used to encode a source input.
	 * 
	 * @param filePath The path of the file containing the encoder dictionary.
	 * @return The initial encoder dictionary.
	 */
	public abstract Map<Integer, String> loadInitialEncoderDictionary(String filePath);
	
	/**
	 * This method is responsibly to load the initial dictionary file (only with 
	 * code words), that will be used to decode an encoded input.
	 * 
	 * @param filePath The path of the file containing the decoder dictionary.
	 * @return The initial decoder dictionary.
	 */
	public abstract Map<Integer, String> loadInitialDecoderDictionary(String filePath);

	/**
	 * This method is responsibly to load an source file which will be encoded.
	 * 
	 * @param filePath The path of the file containing the source input to be encoded.
	 * @return The content of the source file.
	 */
	public abstract String loadSourceFile(String filePath);
	
	/**
	 * This method is responsibly to load and encoded file which will be decoded.
	 * 
	 * @param filePath The path of the file containing the encoded input to be decoded.
	 * @return The content of the encoded file.
	 */
	public abstract String loadEncodedFile(String filePath);
	
	/**
	 * This method is responsibly to generate an encoded file based on the encoded
	 * information. The generated file will be used to be decoded in the future.
	 * 
	 * @param filePath The file path that will be generated.
	 * @param encoded The encoded information that will be written in the file.
	 */
	public abstract void generateEncodedFile(String filePath, String encoded);
	
	/**
	 * Method created with the responsibility to create a file with the reported 
	 * sequence by the user.
	 * 
	 * @author Gutembergrcc
	 * @param sequence
	 * @param filePath
	 * @throws IOException
	 */
	public abstract void generateFileSequence(String sequence, String filePath);
	
}
